package com.easy.stock.spider;

import java.util.concurrent.Future;

import com.ning.http.client.AsyncHttpClient;
import com.ning.http.client.Response;

/**
 * 表示单个抓取任务
 * 
 * @author simonlin
 */
public class SpiderTask {
	
	public static enum STATUS {
		RUNNING,
		READY,
		FAILED,
		SUCCESS,
	}

	private String url;
	
	private BaseAsyncCompletionHandler handler;
	
	private Future<Response> future;
	
	public AsyncHttpClient getAsyncHttpClient() {
		return asyncHttpClient;
	}

	public void setAsyncHttpClient(AsyncHttpClient asyncHttpClient) {
		this.asyncHttpClient = asyncHttpClient;
	}

	private AsyncHttpClient asyncHttpClient;

	
	private STATUS status;
	
	private int retryNum;
	
	public SpiderTask(String url, BaseAsyncCompletionHandler handler, STATUS status) {
		this.url = url;
		this.handler = handler;
		handler.setTask(this);
		this.status = status;
	}
	
	public STATUS getStatus() {
		return status;
	}

	public void setStatus(STATUS status) {
		this.status = status;
	}

	public int getRetryNum() {
		return retryNum;
	}

	public void setRetryNum(int retryNum) {
		this.retryNum = retryNum;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public BaseAsyncCompletionHandler getHandler() {
		return handler;
	}

	public void setHandler(BaseAsyncCompletionHandler handler) {
		this.handler = handler;
	}
	
	public Future<Response> getFeature() {
		return future;
	}

	public void setFuture(Future<Response> future) {
		this.future = future;
	}

	
}
